//
//  HRStatus.swift
//  microBlog
//
//  Created by HR_W on 16/5/24.
//  Copyright © 2016年 admin. All rights reserved.
//

import UIKit

class HRStatus: NSObject {
    
    
    var id: Int64 = 0
    
    var text: String?
    var created_at: String?
    
    var source: String?
    var user: HRUser?
    
    var retweeted_status: HRStatus?
    
    //转发数量
    var reposts_count: Int = 0
    //评论
    var comments_count: Int = 0
    //攒
    var attitudes_count: Int = 0
    
    
    var pic_urls: [HRPicture]?
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let dict = value as? [String: AnyObject] {
                
                user = HRUser(dict: dict)
                
            }
            return
        }
        
        if key == "pic_urls" {
            
            if let array = value as? [[String: AnyObject]]{
            
                var tempArray = [HRPicture]()
                
                for item in array {
                    
                    let p = HRPicture(dict: item)
                    
                    tempArray.append(p)
                    
                }
                pic_urls = tempArray
            }
            return
        }
        
        if key == "retweeted_status" {
            
            if let dict = value as? [String: AnyObject]{
            
            retweeted_status = HRStatus(dict: dict)
            
            }
            
            return
        }
        
       super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    
    }

}
